﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

using RssToolkit.Rss;
using OpenSocialPlugin.Providers;

namespace test
{
  public partial class Form2 : Form
  {
    public Form2()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      //album
      RssDocument doc = RssDocument.Load(BaseSite.GetWebData("http://feed105.photobucket.com/groups/m228/CV1ARFWWH1/feed.rss"));
      foreach (var rssItem in doc.Channel.Items)
      {
        string id = rssItem.Link.Replace("http://photobucket.com/groups", "http://feed.photobucket.com/groups") + "/feed.rss";
        Regex regexObj = new Regex("<img src=\"(.*?)\"", RegexOptions.Singleline);
        string thumb = regexObj.Match(rssItem.Description).Groups[1].Value;
        string title = rssItem.Title;
      }


    }

    public void photopoinstTest()
    {

      string site = BaseSite.GetWebData("http://www.photopoints.com/main/rss/default.aspx");
      string siteurl = "";
      try
      {
        Regex regexObj = new Regex("CategoryName\">(.*?)</span>.*?title=\"RSS Feed\" href=\"(.*?)\" target=\"_blank\">", RegexOptions.Singleline);
        Match matchResult = regexObj.Match(site);
        while (matchResult.Success)
        {
          string name = (matchResult.Groups[1].Value);
          siteurl = "http://www.photopoints.com" + (matchResult.Groups[2].Value);
          matchResult = matchResult.NextMatch();
        }
      }
      catch (ArgumentException ex)
      {
        // Syntax error in the regular expression
      }

      RssDocument doc = RssDocument.Load(BaseSite.GetWebData(siteurl));
      foreach (var rssItem in doc.Channel.Items)
      {
        Regex regexObj = new Regex("thumbID=(.*?)&", RegexOptions.Singleline);
        string id = regexObj.Match(rssItem.Description).Groups[1].Value;
        string imgurl = string.Format("http://www.photopoints.com/main/photos/streamthumb.aspx?thumbID={0}&thumbSize=1000", id);
      }
      
    }
  }
}
